package rule03;

/**
 * @author ChangLiang
 * @date 2020/3/16
 */
public final class SingletonObject5 {

    private static volatile SingletonObject5 instance;

    private SingletonObject5(){}

    public static SingletonObject5 getInstance() {
        if (null == instance) {
            synchronized (SingletonObject5.class) {
                if (null == instance) {
                    // volatile定义的东西，完成之后，就代表其真正的完成了
                    instance = new SingletonObject5();
                }
            }
        }
        return SingletonObject5.instance;
    }
}
